package com.xxxx.caseClass

/**
 * @program: day0303
 * @description: 尽信书，则不如无书
 * @author: CoreDao
 * @create: 2021-03-03 17:49
 * */
//有get\set\equals\toString等，Bean对象的内容
//样例类：特殊类，超人，对于自己使用而言方便，省心
case class Student(name:String,age:Int)

object CaseClassTest {
  def main(args: Array[String]): Unit = {
    Tuple2

    val student: Student = Student("zs", 19)
    val student2: Student = Student("lisi", 24)
    val student3: Student = Student("wangwu", 19)

    val student1 = new Student("llis", 20)
    println(student)
    println(student1)
    val str: String = "zs" //看hashcode方法
    //equals方法是如何执行的？以string为例，先比地址，在比长度，再去比字符数组中的值是否一一对应
    println(student.equals(student1))

    val list = List(student, student1, student2,student3)
    list.foreach{x => {
      x match {
        case Student("zs",19) => println("zs")
        case Student("llis",20) => println("lisi")
        case _ => println("others")
      }
    }}

  }
}
